<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>


<link rel="stylesheet" type="text/css" href="../resources/stylesheets/commonStyle.css">
<link rel="stylesheet" href="http://code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.css">
<link rel="stylesheet" type="text/css" href="../resources/stylesheets/jquery.autocomplete.css" />


<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
<script type="text/javascript" src="../resources/js/jquery.autocomplete.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.0.0.js"></script>
<script type="text/javascript">

$(document).ready(function() {
	//alert("auto");
		$("#autoComp").autocomplete("AjaxController.do");
		$( "#datepicker" ).datepicker();
	});

 var xmlHttp;

function loadSubCategory(category){
	  var url="AjaxController.do?categoryName="+category;
	  startSubCategoryRequest(url);
	  return true;
}

//Fetch Category from BD.
function categoryOnLoad(){
	  //var categoryId=document.getElementById("category").value;
	  var url="AjaxController.do?category=Y";
	  startCategoryRequest(url);
	  return true;
}

function createXMLHttpRequest(){
	  if(window.ActiveXObject){
	  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	   }
	   else if(window.XMLHttpRequest){
	    xmlHttp=new XMLHttpRequest();

	   }
	   return true;
	  }

function startCategoryRequest(url){
	  createXMLHttpRequest();
	  xmlHttp.onreadystatechange=function()
 		 {
  			if (xmlHttp.readyState==4 && xmlHttp.status==200)
   			 {
    			document.getElementById("category").innerHTML=xmlHttp.responseText;
   			 }
 		 };
	  xmlHttp.open("GET",url,true);
	  xmlHttp.send(null);
	  return true;
	  }

function startSubCategoryRequest(url){
	  createXMLHttpRequest();
	  xmlHttp.onreadystatechange=function()
		 {
			if (xmlHttp.readyState==4 && xmlHttp.status==200)
 			 {
  				document.getElementById("subcategory").innerHTML=xmlHttp.responseText;
 			 }
		 };
	  xmlHttp.open("GET",url,true);
	  xmlHttp.send(null);
	  return true;
	  }
function validateTask(){
	var userName=document.getElementById("title").value;
	var userAssign=document.getElementById("assignTo").value;
	var userDeadline=document.getElementById("userDeadline").value;

	if(userName==""){
		alert("Please enter Title");
		document.getElementById("title").focus();
	}

	if(userAssign==""){
		alert("Please enter Assigned Person Name");
		document.getElementById("assignTo").focus();

	}
	if(userDeadline==""){
		alert("Please enter the Deadline");
		document.getElementById("userDeadline").focus();

	}
	
 </script>
</head>

<body onload="categoryOnLoad()">


<%@ include file="header.jsp" %>
<div id="nav">

</div>

<div id="section">
<h3 align="justify">ASSIGNING INDIVIDUAL TASK </h3>
<form method="post" action="taskAction.do" enctype="multipart/form-data">
<input type="hidden" name="pageName" value="assignTask" />
<table style="width:100%">
<tr>
<td class="required">Title</td>
<form action="userAction.do" method="post">
<td> <input type="text" name="Title" required id="title"></td>
</tr>
<tr>
<td class="required">Category</td>
<td><select name="category" id="category" onchange="loadSubCategory(this.value);">
  </select> </td>
</tr>
<tr>
<td class="required">Sub-Category</td>
<td><select name="subcategory" id="subcategory" >
  </select> </td>
</tr>
<tr>
<td class="required">Assign To</td>
<form action="userAction.do" method="post">
<td> <input type="text" name="AssignTo" required id="assignTo" id="autoComp"></td>
</tr>

<tr>
<td class="required">Priority</td>
<td><select name="Priority">
  <option value="p1">p1</option>
  <option value="p2">p2</option>
  <option value="p3">p3</option>

</select> </td>
</tr>
<tr>
<td class="required">Deadline</td>
<form action="userAction.do" method="post">
<td><input type="date" name="Deadline" required id="userDeadline" id="datepicker"><br>
</td>
</tr>


<tr>
<td>Domain</td>
<td><input type="text" name="Domain" value="MNA" id="Domain" readonly></td>
</tr>

<tr>
<td>Sub-Domain</td>
<td><select name="SubDomain">
  <option value="MIO">MIO</option>
  <option value="MSDP">MSDP</option>
  <option value="MSP">MSP</option>
  <option value="MPS">MPS</option>
  <option value="Others">Others</option>
  </select> </td>
</tr>

<tr>
<td >Task Details</td>
<td><textarea rows="4" cols="20" name="TaskDetails">
</textarea></td>
</tr>


<tr>
<td >Upload File</td>
<td><input type="file" name="attachment" id="attachment"></td>

</tr>
<tr>
     <td></td>
    
		<td align="left"><input type="submit" value="Assign Task" class="btn" onclick="validateTask()">
		<input type="reset" value="Reset Task" class="btn"></td>
	</tr>
</table>
 </form>
</div>
<%@ include file="footer.jsp" %>
</body>
</html>
